package com.blackink.tool;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

public class RandomString {
    public static String getRandomSalt() {
        String model ="abcdefghijklmnopqrstuvwxyz1234567890";
        StringBuffer salt = new StringBuffer();
        char[] m = model.toCharArray();
        for (int i = 0; i < 10; i++) {
            char c = m[(int) (Math.random() * 36)];
            salt = salt.append(c);
        }
        return salt.toString();
    }

    public static void main(String[] args) {
        String source = "123456";
        String salt = "adminadmin";
        Integer hashIterations = 1;
        Md5Hash md5Hash = new Md5Hash(source,salt,hashIterations);
        System.out.println(md5Hash.toString());
        SimpleHash simpleHash = new SimpleHash("md5",source,salt,hashIterations);
        System.out.println(simpleHash.toString());


//        Date date = new Date();
//        SimpleDateFormat format = new SimpleDateFormat("YY-MM-dd HH:mm:ss");
//        String d = format.format(date);
//        System.out.println(format.format(date));

    }
}
